package com.javasea.mq.ack.controller;

import com.javasea.mq.ack.entity.Order;
import com.javasea.mq.ack.service.OrderService;
import com.javasea.mq.ack.service.impl.RabbitOrderSender;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 *@ClassName Demo
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2022/4/25 0025 0:40
 */
@RestController
public class Demo {

    @Autowired
    private RabbitOrderSender rabbitOrderSender;

    /** http://localhost:8001/testSender2
     *  测试直接发送
     * */
    @GetMapping("testSender2")
    public void testSender2() throws Exception {
        Order order = new Order();
        order.setId(2018080400000001L);
        order.setName("测试订单");
        order.setMessageId(System.currentTimeMillis());
        rabbitOrderSender.sendOrder(order);
    }

    @Autowired
    private OrderService orderService;

    /** http://localhost:8001/testCreateOrder
     * 发送成功 并且入库OK:业务表 和 消息记录表均有数据 且status状态=1 为成功！
     * @throws Exception
     */
    @GetMapping("testCreateOrder")
    public void testCreateOrder() throws Exception {
        Order order = new Order();
        order.setId(2018080400000002L);
        order.setName("测试创建订单");
        order.setMessageId(System.currentTimeMillis());
        orderService.createOrder(order);
    }

}
